/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alvaro
 */
@Entity
@Table(name = "candidate_tags")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CandidateTags.findAll", query = "SELECT c FROM CandidateTags c"),
    @NamedQuery(name = "CandidateTags.findByCandidateAndTag", query = "SELECT c FROM CandidateTags c WHERE c.candidate = :candidate AND c.tag =:tag"),
    @NamedQuery(name = "CandidateTags.findByIdCandidateTags", query = "SELECT c FROM CandidateTags c WHERE c.idCandidateTags = :idCandidateTags"),
    @NamedQuery(name = "CandidateTags.findByTag", query = "SELECT DISTINCT c.tag FROM CandidateTags c WHERE c.tag like :tag")})
public class CandidateTags implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_CANDIDATE_TAGS")
    private Integer idCandidateTags;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "TAG")
    private String tag;
    @JoinColumn(name = "CANDIDATE", referencedColumnName = "ID_CANDIDATE")
    @ManyToOne(optional = false)
    private Candidate candidate;

    public CandidateTags() {
    }

    public CandidateTags(Integer idCandidateTags) {
        this.idCandidateTags = idCandidateTags;
    }

    public CandidateTags(Integer idCandidateTags, String tag) {
        this.idCandidateTags = idCandidateTags;
        this.tag = tag;
    }

    public Integer getIdCandidateTags() {
        return idCandidateTags;
    }

    public void setIdCandidateTags(Integer idCandidateTags) {
        this.idCandidateTags = idCandidateTags;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public Candidate getCandidate() {
        return candidate;
    }

    public void setCandidate(Candidate candidate) {
        this.candidate = candidate;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCandidateTags != null ? idCandidateTags.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CandidateTags)) {
            return false;
        }
        CandidateTags other = (CandidateTags) object;
        if ((this.idCandidateTags == null && other.idCandidateTags != null) || (this.idCandidateTags != null && !this.idCandidateTags.equals(other.idCandidateTags))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CandidateTags[ idCandidateTags=" + idCandidateTags + " ]";
    }
    
}
